"use client"; import { useEffect, useState } from "react"; import { useTranslations } from "next-intl"; import { Link } from "@/i18n/navigation"; import { useAuth } from "@/providers/auth-provider"; import { History, ArrowLeft, Loader2 } from "lucide-react"; import { fetchWithdrawalList, getWithdrawalStatusLabel, type WithdrawalRecord, } from "@/lib/withdrawal-api"; import { cn } from "@/lib/utils"; const PAGE_SIZE = 10; export default function AccountWithdrawalsPage() { const t = useTranslations("account"); const { user, isReady } = useAuth(); const [records, setRecords] = useState([]); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); const [page, setPage] = useState(1); useEffect(() => { if (!user) return; let cancelled = false; async function loadRecords() { setLoading(true); setError(null); try { const list = await fetchWithdrawalList({ current: page, row: PAGE_SIZE }); if (cancelled) return; setRecords(list); } catch (e) { if (cancelled) return; setError((e as Error).message || "领取记录加载失败,请稍后重试。"); setRecords([]); } finally { if (!cancelled) setLoading(false); } } void loadRecords(); return () => { cancelled = true; }; }, [user, page]); if (!isReady) return
; if (!user) { return (

您尚未登录

立即登录
); } const hasPrev = page > 1; const hasNext = records.length >= PAGE_SIZE; function getStatusStyle(status: number | string) { const s = String(status); if (s === "2" || s === "3") return "text-emerald-400 border-emerald-400/30 bg-emerald-400/10"; if (s === "4" || s === "5") return "text-rose-400 border-rose-400/30 bg-rose-400/10"; return "text-amber-400 border-amber-400/30 bg-amber-400/10"; } return (

全部领取记录

追踪您的每一笔资金变动状态

返回控制中心
{loading ?
: null} {error ?
{error}
: null} {!loading && !error && records.length === 0 ? (

暂无领取记录。

) : null} {!loading && !error && records.length > 0 ? (
{records.map((w) => (

{w.details}

流水号: {w.serial} 申请: {w.addTime || "-"} {w.payTime && <>到账: {w.payTime}}

${w.amount}

{getWithdrawalStatusLabel(w.status)}
))}
) : null} {/* 分页 */} {!loading && !error && (hasPrev || hasNext) && (
{page}
)}
); }